#include<iostream>
#include<fstream>
#include<string>
using namespace std;
const double critsc=0.6;
const int critmo=3;
struct node
{
    string a[2];
    double b;
    int c;
};
ifstream fin;
ofstream fout;
bool getitem(node *tt)
{
    if(!fin.eof())
    {
	fin>>tt->a[0]>>tt->a[1];
	fin>>tt->b>>tt->c;
	return 0;
    }
    else 
	return 1;
}
int main()
{
    node *head;
    node *tt,*tail;
    head=new node;
    tail=tt=head;
    getitem(tail);
    fin.open("/home/pi/code/al/month_operate.txt");
    fout.open("/home/pi/code/al/newR.txt",ios_base::app);
    bool ot=0;
    int d=0;
    while(true)
    {
	tt=new node;
	if(!getitem(tt))
	{
	    if(tt->a[0]==tail->a[0])
	    {
		if(ot==0)
		{
		    if(tail->b>=critsc||tail->c>=critmo)
		    {
			fout<<tail->a[0]<<"\t"<<tail->a[1];
			ot=1;
			d++;
		    }
		    delete tail;
		    tail=tt;
		}
		else if(ot==1)
		{
		    if(tail->b>=critsc||tail->c>=critmo)
		    {
			fout<<","<<tail->a[1];
			d++;
		    }
		    delete tail;
		    tail=tt;
		}
	    }
	    else
	    {
		fout<<endl;
		if(ot==0)
		{
		    if(tail->b>=critsc||tail->c>=critmo)
		    {
			fout<<tail->a[0]<<"\t"<<tail->a[1];
			ot=1;
			d++;
		    }
		    delete tail;
		    tail=tt;

		}
		else if(ot==1)
		{
		    if(tail->b>=critsc||tail->c>=critmo)
		    {
			fout<<tail->a[0]<<","<<tail->a[1];
			d++;
		    }
		    delete tail;
		    ot=0;
		    tail=tt;
		}
	    }
	}
	else
	    break;
    }
    cout<<d<<endl;
    fout.close();
}

